import { Observer } from "mobx-vue"
import { Component, Vue } from "vue-property-decorator";
import { addCommunity } from 'src/utils/axios';
import PubArea from 'src/views/components/pubArea/pubArea.vue';
@Observer
@Component({
  props: {
    clear: {
      type: Boolean,
      default: false
    }
  },
  components: {
    PubArea
  }
})
export default class CommunityAdd extends Vue {
  isShowModel: boolean = false;
  formItem:any={
    name:"",
    contact:"",
    telephone:"",
    address:"",
    community_code:""
  }
  mounted() {
    let vm: any = this;
    vm.isShowModel = true;
  }
  //关闭
  close() {
    let vm: any = this;
    let xwindow: any = window
    vm.isShowModel = false;
    if (!vm.clear) {
      xwindow.clearBodyStyle()
    }
    vm.$emit('close')
  }
  //确定
  async confirm() {
    let vm: any = this;
    let xwindow: any = window
    let areaParams=vm.$refs.area.formInline;
    let param={street_code:areaParams.street_code,...vm.formItem}
    let out:any = await addCommunity(param);
    if (!out.status) {
          vm.isShowModel = false;
          if (!vm.clear) {
              xwindow.clearBodyStyle()
          }
          vm.$emit('confirm')
    }else {
      vm.$Message.error(out.error.msg)
    }
  }
 }
 